// packageB/pages/choujiang/choujiang.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    appurl: app.apiurl,
    apiimg: app.apiimg,
    qiandao:'',
    tanchuang4:false,
    tanchuang5:false,
    jieguo:0,
    jietu1:'',
    jietu2:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.z_yonghu()
    this.z_peizhi()
    this.z_baoxiang2()
  },
  z_peizhi(){
    let _this = this
    let params = {
      "token":wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/config/configBase',
      method: 'GET',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        _this.setData({
          peizhi: res.data.data
        })
        let show_liaoliao = res.data.data.config_param55
        if(show_liaoliao == '1'){
          _this.setData({
            show_liaoliao_flag:true
          })
        }
      }
    })
  },
  z_yonghu() {
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/member/myInfo',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        if (res.data.code == '1001') {
          _this.setData({
            login: true,
            yonghu: res.data.data
          })
        }
      }
    })
  },
  z_baoxiang2() {
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
    }
    wx.request({
      url: app.apiurl + 'api/season/beishuList',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        _this.setData({
          lucksData2: res.data.data
        })
      }
    })
  },
  z_open1(){
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
      "sign_type":"1"
    }
    wx.request({
      url: app.apiurl + 'api/season/memberSign',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        let str = res.data.data.index_num;
        let num = parseInt(str);
        _this.setData({
          jieguo:num,
          qiandao:res.data.data
        })
      }
    })
  },
  luckCb(e){
    let _this = this
  setTimeout(function(){
    console.log(e);
    _this.setData({
      tanchuang5:true,
    })
  },7000)
  },
  z_open(){
    let _this = this
    let params = {
      "token": wx.getStorageSync("user_token"),
      "sign_type":"2"
    }
    wx.request({
      url: app.apiurl + 'api/season/memberSign',
      method: 'POST',
      data: params,
      header: {
        'content-type': 'application/x-www-form-urlencoded' // 修改请求
      },
      success(res) {
        _this.setData({
          tanchuang4:true,
          qiandao:res.data.data
        })
      }
    })
  },
  z_close(){
    this.setData({
      tanchuang4:false,
      tanchuang5:false,
    })
    wx.navigateBack({
      delta: 0,
    })
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})